package org.scala.javafx.rich

import javafx.scene.Node
import javafx.scene.input.MouseEvent
import javafx.event.EventHandler

class RichNode(raw: Node) {
  def onMouseClicked(f: MouseEvent => Unit) = raw.setOnMouseClicked(new EventHandler[MouseEvent] {
    def handle(event: MouseEvent): Unit = f(event)
  })
  
  def setOnMouseDragged(f: MouseEvent => Unit) = raw.setOnMouseClicked(new EventHandler[MouseEvent] {
    def handle(event: MouseEvent): Unit = f(event)
  })
  
  def setOnMouseEntered(f: MouseEvent => Unit) = raw.setOnMouseClicked(new EventHandler[MouseEvent] {
    def handle(event: MouseEvent): Unit = f(event)
  })
  
  def setOnMouseExited(f: MouseEvent => Unit) = raw.setOnMouseClicked(new EventHandler[MouseEvent] {
    def handle(event: MouseEvent): Unit = f(event)
  })
  
  def setOnMouseMoved(f: MouseEvent => Unit) = raw.setOnMouseClicked(new EventHandler[MouseEvent] {
    def handle(event: MouseEvent): Unit = f(event)
  })
  
  def setOnMousePressed(f: MouseEvent => Unit) = raw.setOnMouseClicked(new EventHandler[MouseEvent] {
    def handle(event: MouseEvent): Unit = f(event)
  })
  
  def setOnMouseReleased(f: MouseEvent => Unit) = raw.setOnMouseClicked(new EventHandler[MouseEvent] {
    def handle(event: MouseEvent): Unit = f(event)
  })
}